```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>面向对象编程 - Java核心概念</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', 'Noto Serif SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            line-height: 1.8;
            color: #333;
            background-color: #f9fafb;
        }
        .hero {
            background: linear-gradient(135deg, #6b46c1 0%, #805ad5 100%);
            color: white;
        }
        .card {
            transition: all 0.3s ease;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
        }
        .card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
        }
        .concept-diagram {
            background: white;
            border-radius: 0.5rem;
            padding: 1.5rem;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
        }
        .feature-icon {
            font-size: 2rem;
            color: #6b46c1;
            margin-bottom: 1rem;
        }
        .section-title {
            position: relative;
            padding-bottom: 0.5rem;
        }
        .section-title:after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 0;
            width: 3rem;
            height: 3px;
            background: #6b46c1;
        }
        .code-block {
            background: #2d3748;
            color: #f7fafc;
            border-radius: 0.375rem;
            font-family: 'Courier New', Courier, monospace;
        }
        .comparison-table {
            background: white;
            border-radius: 0.5rem;
            overflow: hidden;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
        }
        .comparison-table th {
            background-color: #6b46c1;
            color: white;
        }
        .comparison-table tr:nth-child(even) {
            background-color: #f8f9fa;
        }
        .floating-nav {
            position: sticky;
            top: 2rem;
        }
        .nav-link {
            transition: all 0.2s ease;
        }
        .nav-link:hover {
            color: #6b46c1;
            transform: translateX(5px);
        }
        .footer {
            background: #2d3748;
            color: #f7fafc;
        }
        .footer a:hover {
            color: #a0aec0;
        }
        .highlight {
            background: rgba(107, 70, 193, 0.1);
            border-left: 4px solid #6b46c1;
            padding: 0.5rem 1rem;
        }
    </style>
</head>
<body class="antialiased">
    <!-- Hero Section -->
    <section class="hero py-20 px-4 md:px-0">
        <div class="container mx-auto max-w-6xl flex flex-col md:flex-row items-center">
            <div class="md:w-1/2 mb-10 md:mb-0">
                <h1 class="text-4xl md:text-5xl font-bold mb-6">面向对象编程</h1>
                <h2 class="text-2xl md:text-3xl font-semibold mb-6 opacity-90">Java核心概念精解</h2>
                <p class="text-lg mb-8 opacity-90 leading-relaxed">
                    面向对象编程(OOP)是Java的灵魂所在，也是现代软件开发中最重要的编程范式之一。掌握OOP思想和方法将为你的编程之旅打下坚实基础。
                </p>
                <div class="flex space-x-4">
                    <a href="#basic-concepts" class="bg-white text-purple-700 hover:bg-purple-100 px-6 py-3 rounded-lg font-medium transition duration-300">
                        核心概念 <i class="fas fa-arrow-down ml-2"></i>
                    </a>
                    <a href="#java-features" class="border-2 border-white text-white hover:bg-white hover:text-purple-700 px-6 py-3 rounded-lg font-medium transition duration-300">
                        Java特性 <i class="fas fa-code ml-2"></i>
                    </a>
                </div>
            </div>
            <div class="md:w-1/2 flex justify-center">
                <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1735198473689-41cbb5c5-2b57-40da-a2b6-067ea57086f4.png" 
                     alt="面向对象编程概念图" 
                     class="rounded-lg shadow-xl w-full max-w-md">
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <div class="container mx-auto max-w-6xl px-4 py-12">
        <div class="flex flex-col md:flex-row">
            <!-- Sidebar Navigation -->
            <div class="md:w-1/4 pr-8 mb-10 md:mb-0">
                <div class="floating-nav bg-white p-6 rounded-lg shadow-md">
                    <h3 class="text-xl font-bold mb-4 text-gray-800">内容导航</h3>
                    <ul class="space-y-3">
                        <li><a href="#basic-concepts" class="nav-link flex items-center text-gray-700"><i class="fas fa-dot-circle mr-2 text-sm text-purple-600"></i> 基本概念</a></li>
                        <li><a href="#java-features" class="nav-link flex items-center text-gray-700"><i class="fas fa-dot-circle mr-2 text-sm text-purple-600"></i> Java特性</a></li>
                        <li><a href="#advanced-class" class="nav-link flex items-center text-gray-700"><i class="fas fa-dot-circle mr-2 text-sm text-purple-600"></i> 类的高级特性</a></li>
                        <li><a href="#methods-constructors" class="nav-link flex items-center text-gray-700"><i class="fas fa-dot-circle mr-2 text-sm text-purple-600"></i> 方法与构造器</a></li>
                        <li><a href="#access-control" class="nav-link flex items-center text-gray-700"><i class="fas fa-dot-circle mr-2 text-sm text-purple-600"></i> 访问控制</a></li>
                        <li><a href="#inheritance-composition" class="nav-link flex items-center text-gray-700"><i class="fas fa-dot-circle mr-2 text-sm text-purple-600"></i> 继承与组合</a></li>
                    </ul>
                </div>
            </div>

            <!-- Content -->
            <div class="md:w-3/4">
                <!-- Basic Concepts Section -->
                <section id="basic-concepts" class="mb-16">
                    <h2 class="section-title text-3xl font-bold text-gray-800 mb-8">面向对象的基本概念</h2>
                    
                    <div class="highlight mb-8">
                        <p class="text-lg">面向对象编程(OOP)是一种以对象为核心，通过模拟现实世界事物的属性和行为来设计和开发软件的编程范式。</p>
                    </div>
                    
                    <div class="grid md:grid-cols-2 gap-8 mb-10">
                        <div class="card bg-white p-6 rounded-lg">
                            <div class="flex items-center mb-4">
                                <div class="bg-purple-100 p-3 rounded-full mr-4">
                                    <i class="fas fa-cube text-purple-600 text-xl"></i>
                                </div>
                                <h3 class="text-xl font-bold text-gray-800">类与对象</h3>
                            </div>
                            <p class="text-gray-700 mb-4">
                                <strong>类(Class)</strong>是对象的模板或蓝图，定义了一组具有相同属性和行为的对象。类中包含属性(字段)和方法(行为)的定义。
                            </p>
                            <p class="text-gray-700 mb-4">
                                <strong>对象(Object)</strong>是类的实例，是具体的、有实际值的实体。每个对象有自己的状态(属性值)和行为(方法的调用)。
                            </p>
                        </div>
                        
                        <div class="card bg-white p-6 rounded-lg">
                            <div class="flex items-center mb-4">
                                <div class="bg-purple-100 p-3 rounded-full mr-4">
                                    <i class="fas fa-lock text-purple-600 text-xl"></i>
                                </div>
                                <h3 class="text-xl font-bold text-gray-800">封装</h3>
                            </div>
                            <p class="text-gray-700 mb-4">
                                将对象的属性和方法封装在类中，隐藏其内部实现，仅通过公开的接口(getter和setter方法)与外部交互。
                            </p>
                            <div class="code-block p-4 rounded text-sm overflow-x-auto">
                                <pre><code class="text-white">public class Student {
    private String name;  // 私有属性
    public String getName() {  // 公开访问方法
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
}</code></pre>
                            </div>
                        </div>
                        
                        <div class="card bg-white p-6 rounded-lg">
                            <div class="flex items-center mb-4">
                                <div class="bg-purple-100 p-3 rounded-full mr-4">
                                    <i class="fas fa-sitemap text-purple-600 text-xl"></i>
                                </div>
                                <h3 class="text-xl font-bold text-gray-800">继承</h3>
                            </div>
                            <p class="text-gray-700 mb-4">
                                通过继承，子类可以复用父类的属性和方法，并扩展新的功能。Java中通过<code class="bg-gray-100 px-1 rounded">extends</code>关键字实现继承。
                            </p>
                            <div class="code-block p-4 rounded text-sm overflow-x-auto">
                                <pre><code class="text-white">public class Animal {
    public void eat() {
        System.out.println("Animal is eating.");
    }
}
public class Dog extends Animal {
    public void bark() {
        System.out.println("Dog is barking.");
    }
}</code></pre>
                            </div>
                        </div>
                        
                        <div class="card bg-white p-6 rounded-lg">
                            <div class="flex items-center mb-4">
                                <div class="bg-purple-100 p-3 rounded-full mr-4">
                                    <i class="fas fa-random text-purple-600 text-xl"></i>
                                </div>
                                <h3 class="text-xl font-bold text-gray-800">多态</h3>
                            </div>
                            <p class="text-gray-700 mb-4">
                                多态指同一个方法在不同对象中具有不同的实现，分为编译时多态(方法重载)和运行时多态(方法重写)。
                            </p>
                            <div class="code-block p-4 rounded text-sm overflow-x-auto">
                                <pre><code class="text-white">// 方法重载
public class Calculator {
    public int add(int a, int b) { return a + b; }
    public double add(double a, double b) { return a + b; }
}
// 方法重写
public class Animal {
    public void sound() { System.out.println("Animal sound."); }
}
public class Dog extends Animal {
    @Override
    public void sound() { System.out.println("Dog barks."); }
}</code></pre>
                            </div>
                        </div>
                    </div>
                    
                    <div class="concept-diagram mb-10">
                        <div class="mermaid">
                            classDiagram
                                class 类 {
                                    +属性(字段)
                                    +方法()
                                }
                                类 <|-- 对象 : 实例化
                                类 <|-- 子类 : 继承
                                类 *-- 接口 : 实现
                                类 "1" *-- "n" 对象 : 包含
                        </div>
                    </div>
                    
                    <div class="card bg-white p-6 rounded-lg mb-8">
                        <div class="flex items-center mb-4">
                            <div class="bg-purple-100 p-3 rounded-full mr-4">
                                <i class="fas fa-lightbulb text-purple-600 text-xl"></i>
                            </div>
                            <h3 class="text-xl font-bold text-gray-800">抽象性</h3>
                        </div>
                        <div class="grid md:grid-cols-2 gap-6">
                            <div>
                                <h4 class="font-semibold text-gray-800 mb-2">抽象类(Abstract Class)</h4>
                                <p class="text-gray-700 mb-4">
                                    定义了一种通用的基类结构，可以包含抽象方法(没有实现的方法)。无法直接实例化。
                                </p>
                                <div class="code-block p-4 rounded text-sm overflow-x-auto">
                                    <pre><code class="text-white">abstract class Animal {
    abstract void sound();
}
public class Dog extends Animal {
    @Override
    void sound() { 
        System.out.println("Dog barks."); 
    }
}</code></pre>
                                </div>
                            </div>
                            <div>
                                <h4 class="font-semibold text-gray-800 mb-2">接口(Interface)</h4>
                                <p class="text-gray-700 mb-4">
                                    定义完全抽象的结构，只包含方法的声明(Java 8+支持默认方法和静态方法)。用于实现多继承。
                                </p>
                                <div class="code-block p-4 rounded text-sm overflow-x-auto">
                                    <pre><code class="text-white">interface Vehicle {
    void start();
}
public class Car implements Vehicle {
    @Override
    public void start() { 
        System.out.println("Car starts."); 
    }
}</code></pre>
                                </div>
                            </div>
                        </div>
                    </div>
                </section>

                <!-- Java Features Section -->
                <section id="java-features" class="mb-16">
                    <h2 class="section-title text-3xl font-bold text-gray-800 mb-8">Java 面向对象的特性</h2>
                    
                    <div class="mb-10">
                        <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1735198583497-c07d9974-995c-4f0e-add0-0259b608d35e.png" 
                             alt="Java面向对象特性" 
                             class="rounded-lg w-full">
                    </div>
                    
                    <div class="grid md:grid-cols-2 gap-8 mb-10">
                        <div class="card bg-white p-6 rounded-lg">
                            <div class="feature-icon">
                                <i class="fas fa-box"></i>
                            </div>
                            <h3 class="text-xl font-bold text-gray-800 mb-4">封装</h3>
                            <p class="text-gray-700 mb-4">
                                将对象的属性和行为(方法)封装在一个类中，并通过访问控制符对外界隐藏对象的内部实现细节，仅暴露必要的接口供外界使用。
                            </p>
                            <div class="code-block p-4 rounded text-sm overflow-x-auto">
                                <pre><code class="text-white">public class BankAccount {
    private double balance; // 封装属性
    
    public double getBalance() { // 提供访问方法
        return balance;
    }
    
    public void deposit(double amount) { // 提供功能方法
        if (amount > 0) {
            balance += amount;
        }
    }
}</code></pre>
                            </div>
                        </div>
                        
                        <div class="card bg-white p-6 rounded-lg">
                            <div class="feature-icon">
                                <i class="fas fa-project-diagram"></i>
                            </div>
                            <h3 class="text-xl font-bold text-gray-800 mb-4">继承</h3>
                            <p class="text-gray-700 mb-4">
                                继承是一种通过扩展已有类来创建新类的机制。子类可以继承父类的属性和方法，同时可以添加新的功能或重写父类的方法。
                            </p>
                            <div class="code-block p-4 rounded text-sm overflow-x-auto">
                                <pre><code class="text-white">public class Animal {
    public void eat() {
        System.out.println("Animal is eating.");
    }
}

public class Dog extends Animal { // Dog继承自Animal
    public void bark() {
        System.out.println("Dog is barking.");
    }
}</code></pre>
                            </div>
                        </div>
                    </div>
                    
                    <div class="grid md:grid-cols-2 gap-8 mb-10">
                        <div class="card bg-white p-6 rounded-lg">
                            <div class="feature-icon">
                                <i class="fas fa-shapes"></i>
                            </div>
                            <h3 class="text-xl font-bold text-gray-800 mb-4">多态</h3>
                            <p class="text-gray-700 mb-4">
                                多态是指相同的操作在不同的对象上具有不同的行为，分为编译时多态(方法重载)和运行时多态(方法重写)。
                            </p>
                            <div class="code-block p-4 rounded text-sm overflow-x-auto">
                                <pre><code class="text-white">// 方法重写
public class Animal {
    public void sound() {
        System.out.println("Animal makes a sound.");
    }
}
public class Dog extends Animal {
    @Override
    public void sound() { // 方法重写
        System.out.println("Dog barks.");
    }
}</code></pre>
                            </div>
                        </div>
                        
                        <div class="card bg-white p-6 rounded-lg">
                            <div class="feature-icon">
                                <i class="fas fa-atom"></i>
                            </div>
                            <h3 class="text-xl font-bold text-gray-800 mb-4">抽象</h3>
                            <p class="text-gray-700 mb-4">
                                抽象是通过隐藏实现细节，仅暴露必要的功能来简化系统设计的一种思想。它通过抽象类和接口在Java中实现。
                            </p>
                            <div class="code-block p-4 rounded text-sm overflow-x-auto">
                                <pre><code class="text-white">// 接口
interface Vehicle {
    void start();
}

class Car implements Vehicle {
    @Override
    public void start() {
        System.out.println("Car starts.");
    }
}</code></pre>
                            </div>
                        </div>
                    </div>
                    
                    <div class="card bg-white p-6 rounded-lg">
                        <div class="flex items-center mb-4">
                            <div class="bg-purple-100 p-3 rounded-full mr-4">
                                <i class="fas fa-puzzle-piece text-purple-600 text-xl"></i>
                            </div>
                            <h3 class="text-xl font-bold text-gray-800">Java 面向对象特性的综合应用</h3>
                        </div>
                        <p class="text-gray-700 mb-4">
                            Java中的封装、继承、多态和抽象并不是独立存在的，而是相辅相成，共同构成了面向对象编程的完整体系。
                        </p>
                        <ul class="list-disc pl-6 mb-4 text-gray-700 space-y-2">
                            <li><strong>封装</strong>保证了代码的模块化和安全性</li>
                            <li><strong>继承</strong>和<strong>多态</strong>提升了系统的扩展性和灵活性</li>
                            <li><strong>抽象</strong>为复杂系统提供了清晰的设计和标准化接口</li>
                        </ul>
                        <p class="text-gray-700">
                            通过灵活运用这些特性，我们可以设计出高效、可维护且易扩展的面向对象系统。
                        </p>
                    </div>
                </section>

                <!-- Advanced Class Features Section -->
                <section id="advanced-class" class="mb-16">
                    <h2 class="section-title text-3xl font-bold text-gray-800 mb-8">类的高级特性</h2>
                    
                    <div class="card bg-white p-6 rounded-lg mb-8">
                        <div class="flex items-center mb-4">
                            <div class="bg-purple-100 p-3 rounded-full mr-4">
                                <i class="fas fa-layer-group text-purple-600 text-xl"></i>
                            </div>
                            <h3 class="text-xl font-bold text-gray-800">内部类(Inner Class)</h3>
                        </div>
                        <p class="text-gray-700 mb-4">
                            内部类是定义在另一个类内部的类，它主要用于逻辑分组和简化代码。
                        </p>
                        
                        <div class="grid md:grid-cols-2 gap-6">
                            <div>
                                <h4 class="font-semibold text-gray-800 mb-2">成员内部类</h4>
                                <div class="code-block p-4 rounded text-sm overflow-x-auto">
                                    <pre><code class="text-white">public class Outer {
    private String message = "Hello, Inner Class!";
    class Inner {
        public void display() {
            System.out.println(message); // 访问外部类私有属性
        }
    }
}</code></pre>
                                </div>
                            </div>
                            <div>
                                <h4 class="font-semibold text-gray-800 mb-2">静态内部类</h4>
                                <div class="code-block p-4 rounded text-sm overflow-x-auto">
                                    <pre><code class="text-white">public class Outer {
    static class Inner {
        public void display() {
            System.out.println("Static Inner Class");
        }
    }
}</code></pre>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <div class="grid md:grid-cols-2 gap-8 mb-8">
                        <div class="card bg-white p-6 rounded-lg">
                            <div class="flex items-center mb-4">
                                <div class="bg-purple-100 p-3 rounded-full mr-4">
                                    <i class="fas fa-list-ol text-purple-600 text-xl"></i>
                                </div>
                                <h3 class="text-xl font-bold text-gray-800">枚举类(Enum)</h3>
                            </div>
                            <p class="text-gray-700 mb-4">
                                枚举类是一种特殊的类，用于定义一组固定的常量。
                            </p>
                            <div class="code-block p-4 rounded text-sm overflow-x-auto">
                                <pre><code class="text-white">public enum Day {
    MONDAY, TUESDAY, WEDNESDAY;

    public void printDay() {
        System.out.println("Today is " + this.name());
    }
}</code></pre>
                            </div>
                        </div>
                        
                        <div class="card bg-white p-6 rounded-lg">
                            <div class="flex items-center mb-4">
                                <div class="bg-purple-100 p-3 rounded-full mr-4">
                                    <i class="fas fa-code text-purple-600 text-xl"></i>
                                </div>
                                <h3 class="text-xl font-bold text-gray-800">泛型类</h3>
                            </div>
                            <p class="text-gray-700 mb-4">
                                泛型提供了类型参数化的能力，增加了代码的灵活性和类型安全性。
                            </p>
                            <div class="code-block p-4 rounded text-sm overflow-x-auto">
                                <pre><code class="text-white">public class Box<T> {
    private T item;
    public void setItem(T item) { this.item = item; }
    public T getItem() { return item; }
}

public class Pair<K, V> {
    private K key;
    private V value;
    public Pair(K key, V value) {
        this.key = key;
        this.value = value;
    }
}</code></pre>
                            </div>
                        </div>
                    </div>
                    
                    <div class="card bg-white p-6 rounded-lg">
                        <div class="flex items-center mb-4">
                            <div class="bg-purple-100 p-3 rounded-full mr-4">
                                <i class="fas fa-cogs text-purple-600 text-xl"></i>
                            </div>
                            <h3 class="text-xl font-bold text-gray-800">接口的增强(Java 8+)</h3>
                        </div>
                        <div class="grid md:grid-cols-3 gap-6">
                            <div>
                                <h4 class="font-semibold text-gray-800 mb-2">默认方法</h4>
                                <div class="code-block p-4 rounded text-sm overflow-x-auto">
                                    <pre><code class="text-white">interface Vehicle {
    default void start() {
        System.out.println("Vehicle is starting");
    }
}</code></pre>
                                </div>
                            </div>
                            <div>
                                <h4 class="font-semibold text-gray-800 mb-2">静态方法</h4>
                                <div class="code-block p-4 rounded text-sm overflow-x-auto">
                                    <pre><code class="text-white">interface Utility {
    static void print() {
        System.out.println("Static method in interface");
    }
}</code></pre>
                                </div>
                            </div>
                            <div>
                                <h4 class="font-semibold text-gray-800 mb-2">私有方法(Java 9+)</h4>
                                <div class="code-block p-4 rounded text-sm overflow-x-auto">
                                    <pre><code class="text-white">interface Demo {
    private void helper() {
        System.out.println("Private method in interface");
    }
}</code></pre>
                                </div>
                            </div>
                        </div>
                    </div>
                </section>

                <!-- Methods & Constructors Section -->
                <section id="methods-constructors" class="mb-16">
                    <h2 class="section-title text-3xl font-bold text-gray-800 mb-8">方法与构造器</h2>
                    
                    <div class="grid md:grid-cols-2 gap-8 mb-10">
                        <div class="card bg-white p-6 rounded-lg">
                            <div class="flex items-center mb-4">
                                <div class="bg-purple-100 p-3 rounded-full mr-4">
                                    <i class="fas fa-cog text-purple-600 text-xl"></i>
                                </div>
                                <h3 class="text-xl font-bold text-gray-800">方法(Method)</h3>
                            </div>
                            <p class="text-gray-700 mb-4">
                                方法是一个具有特定功能的代码块，可以通过调用来执行对应的操作。方法由访问修饰符、返回值类型、方法名、参数列表和方法体组成。
                            </p>
                            <div class="code-block p-4 rounded text-sm overflow-x-auto">
                                <pre><code class="text-white">public class Demo {
    public int add(int a, int b) { // 方法定义
        return a + b;
    }
}</code></pre>
                            </div>
                            
                            <h4 class="font-semibold text-gray-800 mt-6 mb-3">方法种类</h4>
                            <ul class="list-disc pl-6 text-gray-700 space-y-2">
                                <li><strong>实例方法</strong>：属于对象，必须通过实例调用</li>
                                <li><strong>静态方法</strong>：使用<code class="bg-gray-100 px-1 rounded">static</code>修饰，属于类本身</li>
                                <li><strong>抽象方法</strong>：没有方法体，用于抽象类或接口</li>
                                <li><strong>最终方法</strong>：用<code class="bg-gray-100 px-1 rounded">final</code>修饰，不能被子类重写</li>
                            </ul>
                            
                            <h4 class="font-semibold text-gray-800 mt-6 mb-3">方法重载(Overloading)</h4>
                            <p class="text-gray-700 mb-4">
                                方法名相同，参数列表不同的多个方法构成重载。编译器通过参数类型、数量或顺序区分调用哪个方法。
                            </p>
                            <div class="code-block p-4 rounded text-sm overflow-x-auto">
                                <pre><code class="text-white">public class Calculator {
    public int add(int a, int b) {
        return a + b;
    }
    public double add(double a, double b) {
        return a + b;
    }
}</code></pre>
                            </div>
                        </div>
                        
                        <div class="card bg-white p-6 rounded-lg">
                            <div class="flex items-center mb-4">
                                <div class="bg-purple-100 p-3 rounded-full mr-4">
                                    <i class="fas fa-hammer text-purple-600 text-xl"></i>
                                </div>
                                <h3 class="text-xl font-bold text-gray-800">构造器(Constructor)</h3>
                            </div>
                            <p class="text-gray-700 mb-4">
                                构造器是一种特殊的方法，用于初始化对象。构造器名称必须与类名相同，且没有返回值。
                            </p>
                            <div class="code-block p-4 rounded text-sm overflow-x-auto">
                                <pre><code class="text-white">public class Person {
    private String name;
    public Person(String name) { // 构造器
        this.name = name;
    }
}</code></pre>
                            </div>
                            
                            <h4 class="font-semibold text-gray-800 mt-6 mb-3">构造器特点</h4>
                            <ul class="list-disc pl-6 text-gray-700 space-y-2">
                                <li>无返回值类型(不能声明为<code class="bg-gray-100 px-1 rounded">void</code>)</li>
                                <li>在对象创建时自动调用</li>
                                <li>支持重载</li>
                            </ul>
                            
                            <h4 class="font-semibold text-gray-800 mt-6 mb-3">构造器链调用</h4>
                            <p class="text-gray-700 mb-4">
                                使用<code class="bg-gray-100 px-1 rounded">this()</code>调用当前类的其他构造器，用于简化代码和减少冗余。
                            </p>
                            <div class="code-block p-4 rounded text-sm overflow-x-auto">
                                <pre><code class="text-white">public class Circle {
    private double radius;
    
    public Circle() {
        this(1.0); // 调用有参构造器
    }
    
    public Circle(double radius) {
        this.radius = radius;
    }
}</code></pre>
                            </div>
                        </div>
                    </div>
                    
                    <div class="card bg-white p-6 rounded-lg">
                        <h3 class="text-xl font-bold text-gray-800 mb-4">静态方法与实例方法的区别</h3>
                        <div class="comparison-table w-full overflow-auto">
                            <table class="min-w-full divide-y divide-gray-200">
                                <thead>
                                    <tr>
                                        <th class="px-6 py-3 text-left text-xs font-medium uppercase">特性</th>
                                        <th class="px-6 py-3 text-left text-xs font-medium uppercase">静态方法</th>
                                        <th class="px-6 py-3 text-left text-xs font-medium uppercase">实例方法</th>
                                    </tr>
                                </thead>
                                <tbody class="divide-y divide-gray-200">
                                    <tr>
                                        <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-700">调用方式</td>
                                        <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-700">类名调用</td>
                                        <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-700">实例对象调用</td>
                                    </tr>
                                    <tr>
                                        <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-700">是否依赖对象</td>
                                        <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-700">不依赖对象</td>
                                        <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-700">依赖对象</td>
                                    </tr>
                                    <tr>
                                        <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-700">是否支持多态</td>
                                        <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-700">不支持</td>
                                        <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-700">支持</td>
                                    </tr>
                                    <tr>
                                        <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-700">常见用途</td>
                                        <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-700">工具方法(如<code class="bg-gray-100 px-1 rounded">Math.sqrt</code>)</td>
                                        <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-700">对象行为方法</td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </section>

                <!-- Access Control Section -->
                <section id="access-control" class="mb-16">
                    <h2 class="section-title text-3xl font-bold text-gray-800 mb-8">访问控制与权限修饰符</h2>
                    
                    <div class="card bg-white p-6 rounded-lg mb-8">
                        <p class="text-gray-700 mb-6">
                            在Java中，<strong>访问控制</strong>是通过权限修饰符来实现的。权限修饰符定义了类、方法和变量的访问范围和权限。通过合理使用权限修饰符，开发者可以控制程序中的数据和方法的可见性和访问权限，保证代码的封装性、安全性和可维护性。
                        </p>
                        
                        <div class="grid md:grid-cols-2 gap-6 mb-8">
                            <div>
                                <h3 class="text-xl font-bold text-gray-800 mb-4">访问修饰符</h3>
                                <ul class="space-y-4">
                                    <li>
                                        <h4 class="font-semibold text-gray-800">public</h4>
                                        <p class="text-gray-700">对所有类、包、子类和非子类开放</p>
                                        <div class="code-block p-4 rounded text-sm overflow-x-auto mt-2">
                                            <pre><code class="text-white">public class Demo {
    public int number; // 该字段对所有类可见
    public void display() { // 该方法对所有类可见
        System.out.println("Public method");
    }
}</code></pre>
                                        </div>
                                    </li>
                                    <li>
                                        <h4 class="font-semibold text-gray-800">protected</h4>
                                        <p class="text-gray-700">对同一包中的类和任何子类(包括不同包中的子类)开放</p>
                                        <div class="code-block p-4 rounded text-sm overflow-x-auto mt-2">
                                            <pre><code class="text-white">class Parent {
    protected int protectedValue; // 该字段对同包中的类和子类可见
}
class Child extends Parent {
    public void display() {
        System.out.println(protectedValue); // 子类可以访问父类的protected字段
    }
}</code></pre>
                                        </div>
                                    </li>
                                </ul>
                            </div>
                            <div>
                                <h3 class="text-xl font-bold text-gray-800 mb-4">&nbsp;</h3>
                                <ul class="space-y-4">
                                    <li>
                                        <h4 class="font-semibold text-gray-800">private</h4>
                                        <p class="text-gray-700">仅对定义它的类可见，其他类无法访问</p>
                                        <div class="code-block p-4 rounded text-sm overflow-x-auto mt-2">
                                            <pre><code class="text-white">public class Demo {
    private int number; // 该字段只能在当前类中访问
    private void display() { // 该方法只能在当前类中访问
        System.out.println("Private method");
    }
}</code></pre>
                                        </div>
                                    </li>
                                    <li>
                                        <h4 class="font-semibold text-gray-800">默认访问修饰符(Package-private)</h4>
                                        <p class="text-gray-700">如果没有明确指定访问修饰符，则采用默认访问修饰符，即包级访问(package-private)</p>
                                        <div class="code-block p-4 rounded text-sm overflow-x-auto mt-2">
                                            <pre><code class="text-white">class Demo {
    int number; // 默认访问修饰符，包内可见
    void display() { // 默认访问修饰符，包内可见
        System.out.println("Default access method");
    }
}</code></pre>
                                        </div>
                                    </li>
                                </ul>
                            </div>
                        </div>
                        
                        <div class="card bg-purple-50 p-6 rounded-lg">
                            <div class="flex items-center mb-4">
                                <div class="bg-purple-100 p-3 rounded-full mr-4">
                                    <i class="fas fa-lock-open text-purple-600 text-xl"></i>
                                </div>
                                <h3 class="text-xl font-bold text-gray-800">访问修饰符的使用原则</h3>
                            </div>
                            <div class="grid md:grid-cols-2 gap-6">
                                <div>
                                    <h4 class="font-semibold text-gray-800 mb-2">封装性</h4>
                                    <p class="text-gray-700 mb-4">
                                        通过将类的字段设为<code class="bg-gray-100 px-1 rounded">private</code>，并提供公共的<code class="bg-gray-100 px-1 rounded">getter</code>和<code class="bg-gray-100 px-1 rounded">setter</code>方法，可以限制外部对内部数据的直接访问，防止不当修改。
                                    </p>
                                    <div class="code-block p-4 rounded text-sm overflow-x-auto">
                                        <pre><code class="text-white">public class BankAccount {
    private double balance; // 私有字段，防止直接访问

    public double getBalance() { // 提供公共的getter方法
        return balance;
    }

    public void deposit(double amount) { // 提供公共的方法来修改余额
        if (amount > 0) {
            balance += amount;
        }
    }
}</code></pre>
                                    </div>
                                </div>
                                <div>
                                    <h4 class="font-semibold text-gray-800 mb-2">最小暴露原则</h4>
                                    <p class="text-gray-700">
                                        尽量将类成员的访问控制在最小范围内，只暴露必要的部分。优先使用<code class="bg-gray-100 px-1 rounded">private</code>修饰符，只有在必须让其他类访问时才使用<code class="bg-gray-100 px-1 rounded">protected</code>或<code class="bg-gray-100 px-1 rounded">public</code>。
                                    </p>
                                </div>
                            </div>
                        </div>
                    </div>
                </section>

                <!-- Inheritance & Composition Section -->
                <section id="inheritance-composition" class="mb-16">
                    <h2 class="section-title text-3xl font-bold text-gray-800 mb-8">继承与组合</h2>
                    
                    <div class="card bg-white p-6 rounded-lg mb-8">
                        <div class="flex items-center mb-4">
                            <div class="bg-purple-100 p-3 rounded-full mr-4">
                                <i class="fas fa-project-diagram text-purple-600 text-xl"></i>
                            </div>
                            <h3 class="text-xl font-bold text-gray-800">继承(Inheritance)</h3>
                        </div>
                        <p class="text-gray-700 mb-4">
                            继承是面向对象编程的一个核心特性，它允许一个类从另一个类继承属性和方法。子类继承父类的字段和方法，可以重用父类的代码，并且可以通过方法重写(Override)来定制或增强父类的行为。
                        </p>
                        
                        <div class="grid md:grid-cols-2 gap-6 mb-6">
                            <div>
                                <h4 class="font-semibold text-gray-800 mb-2">继承的优点</h4>
                                <ul class="list-disc pl-6 text-gray-700 space-y-2">
                                    <li><strong>代码复用</strong>：子类可以直接继承父类的代码，避免重复代码</li>
                                    <li><strong>扩展性强</strong>：可以通过重写父类的方法，增强或改变父类的行为</li>
                                    <li><strong>多态性</strong>：继承支持多态，使得子类对象可以被父类引用</li>
                                </ul>
                            </div>
                            <div>
                                <h4 class="font-semibold text-gray-800 mb-2">继承的缺点</h4>
                                <ul class="list-disc pl-6 text-gray-700 space-y-2">
                                    <li><strong>耦合性强</strong>：继承会使得子类与父类紧密耦合</li>
                                    <li><strong>过度继承</strong>：继承层次过深会导致系统的复杂性增加</li>
                                    <li><strong>限制性强</strong>：继承是单继承，即每个子类只能继承一个父类</li>
                                </ul>
                            </div>
                        </div>
                        
                        <div class="code-block p-4 rounded text-sm overflow-x-auto">
                            <pre><code class="text-white">// 父类
public class Animal {
    public void eat() {
        System.out.println("Animal is eating");
    }
}

// 子类
public class Dog extends Animal {
    @Override
    public void eat() {
        System.out.println("Dog is eating");
    }

    public void bark() {
        System.out.println("Dog is barking");
    }
}</code></pre>
                        </div>
                    </div>
                    
                    <div class="card bg-white p-6 rounded-lg mb-8">
                        <div class="flex items-center mb-4">
                            <div class="bg-purple-100 p-3 rounded-full mr-4">
                                <i class="fas fa-puzzle-piece text-purple-600 text-xl"></i>
                            </div>
                            <h3 class="text-xl font-bold text-gray-800">组合(Composition)</h3>
                        </div>
                        <p class="text-gray-700 mb-4">
                            组合是另一种实现类之间关系的方式，它强调对象之间的包含关系，而非继承。组合允许一个类通过成员变量引用其他类的实例，从而实现功能的复用。组合是一种"has-a"关系，即一个对象有一个或多个成员对象。
                        </p>
                        
                        <div class="grid md:grid-cols-2 gap-6 mb-6">
                            <div>
                                <h4 class="font-semibold text-gray-800 mb-2">组合的优点</h4>
                                <ul class="list-disc pl-6 text-gray-700 space-y-2">
                                    <li><strong>低耦合性</strong>：组合关系比继承关系的耦合性低</li>
                                    <li><strong>灵活性高</strong>：组合支持将多个不同的功能组合到一个类中</li>
                                    <li><strong>不受继承的限制</strong>：组合支持多重功能的复用</li>
                                </ul>
                            </div>
                            <div>
                                <h4 class="font-semibold text-gray-800 mb-2">组合的缺点</h4>
                                <ul class="list-disc pl-6 text-gray-700 space-y-2">
                                    <li><strong>需要更多的代码</strong>：组合通常需要更多的代码来实现相同的功能</li>
                                    <li><strong>不支持多态性</strong>：组合无法直接像继承那样通过父类引用实现多态</li>
                                </ul>
                            </div>
                        </div>
                        
                        <div class="code-block p-4 rounded text-sm overflow-x-auto">
                            <pre><code class="text-white">// 引擎类
class Engine {
    public void start() {
        System.out.println("Engine is starting");
    }
}

// 汽车类，包含引擎
public class Car {
    private Engine engine;  // 组合关系，通过成员变量引用Engine类

    public Car() {
        engine = new Engine(); // 创建引擎对象
    }

    public void drive() {
        engine.start();  // 调用引擎的start方法
        System.out.println("Car is driving");
    }
}</code></pre>
                        </div>
                    </div>
                    
                    <div class="card bg-white p-6 rounded-lg">
                        <div class="flex items-center mb-4">
                            <div class="bg-purple-100 p-3 rounded-full mr-4">
                                <i class="fas fa-question-circle text-purple-600 text-xl"></i>
                            </div>
                            <h3 class="text-xl font-bold text-gray-800">继承与组合的选择</h3>
                        </div>
                        
                        <div class="grid md:grid-cols-2 gap-6">
                            <div>
                                <h4 class="font-semibold text-gray-800 mb-2">何时使用继承</h4>
                                <ul class="list-disc pl-6 text-gray-700 space-y-2">
                                    <li><strong>"is-a"关系</strong>：当子类是父类的一种特殊类型时</li>
                                    <li><strong>代码复用</strong>：当需要重用父类的大部分功能时</li>
                                    <li><strong>多态性</strong>：当需要通过父类类型来操作不同子类对象时</li>
                                </ul>
                            </div>
                            <div>
                                <h4 class="font-semibold text-gray-800 mb-2">何时使用组合</h4>
                                <ul class="list-disc pl-6 text-gray-700 space-y-2">
                                    <li><strong>"has-a"关系</strong>：当一个类包含另一个类的实例时</li>
                                    <li><strong>灵活性要求</strong>：如果需要替换某个组件时</li>
                                    <li><strong>避免过深的继承层次</strong>：组合使得代码更加松耦合</li>
                                </ul>
                            </div>
                        </div>
                    </div>
                </section>
            </div>
        </div>
    </div>

    <!-- Footer -->
    <footer class="footer py-8 px-4 md:px-0">
        <div class="container mx-auto max-w-6xl">
            <div class="text-center">
                <h3 class="text-xl font-bold mb-2">技术小馆</h3>
                <p class="mb-4">探索编程世界的无限可能</p>
                <a href="http://www.yuque.com/jtostring" class="text-purple-300 hover:text-purple-100 transition duration-300">www.yuque.com/jtostring</a>
            </div>
        </div>
    </footer>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });
    </script>
</body>
</html>
```